package com.ysd.repository;

import java.util.List;

import javax.transaction.Transactional;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import com.ysd.entity.Modules;

public interface ModelesRepository extends JpaRepository<Modules, Integer>,JpaSpecificationExecutor<Modules> {

	@Query(value="select * from  modules  where ParentId=?1" ,nativeQuery=true)
	@Transactional
	List<Modules>  findByIdfindcheheren(Integer  modeulesid);
	/**
	 * 向中间表添加角色和权限的
	 * @param RoleId
	 * @param ModuleId
	 */
	@Modifying
	@Query(value = "insert into rolemodules VALUES(?1,?2)", nativeQuery = true)
	@Transactional
	void saveModulesrole(String RoleId, Integer ModuleId);
	/**
	 * 删除角色
	 * @param RoleId
	 
	 */
	@Modifying
	@Query(value = "delete from rolemodules where RoleId =?1", nativeQuery = true)
	@Transactional
	void delModulesrole(String RoleId);
	
	
}
